package com.ruoyi.gt.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.gt.domain.GtMovieListInfo;
import com.ruoyi.gt.service.IGtMovieListInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 电影卡片Controller
 *
 * @author xkang
 * @date 2020-06-19
 */
@RestController
@RequestMapping("/gt/movie")
public class GtMovieListInfoController extends BaseController
{
    @Autowired
    private IGtMovieListInfoService gtMovieListInfoService;

    /**
     * 查询电影卡片列表
     */
    @PreAuthorize("@ss.hasPermi('gt:gtmovie:list')")
    @GetMapping("/list")
    public TableDataInfo list(GtMovieListInfo gtMovieListInfo)
    {
        startPage();
        List<GtMovieListInfo> list = gtMovieListInfoService.selectGtMovieListInfoList(gtMovieListInfo);
        return getDataTable(list);
    }

    /**
     * 导出电影卡片列表
     */
    @PreAuthorize("@ss.hasPermi('gt:gtmovie:export')")
    @Log(title = "电影卡片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GtMovieListInfo gtMovieListInfo) throws IOException
    {
        List<GtMovieListInfo> list = gtMovieListInfoService.selectGtMovieListInfoList(gtMovieListInfo);
        ExcelUtil<GtMovieListInfo> util = new ExcelUtil<GtMovieListInfo>(GtMovieListInfo.class);
        util.exportExcel(response, list, "gtmovie");
    }

    /**
     * 获取电影卡片详细信息
     */
    @PreAuthorize("@ss.hasPermi('gt:gtmovie:query')")
    @GetMapping(value = "/{movieId}")
    public AjaxResult getInfo(@PathVariable("movieId") Long movieId)
    {
        return AjaxResult.success(gtMovieListInfoService.selectGtMovieListInfoById(movieId));
    }

    /**
     * 新增电影卡片
     */
    @PreAuthorize("@ss.hasPermi('gt:gtmovie:add')")
    @Log(title = "电影卡片", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody GtMovieListInfo gtMovieListInfo)
    {
        return toAjax(gtMovieListInfoService.insertGtMovieListInfo(gtMovieListInfo));
    }

    /**
     * 修改电影卡片
     */
    @PreAuthorize("@ss.hasPermi('gt:gtmovie:edit')")
    @Log(title = "电影卡片", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody GtMovieListInfo gtMovieListInfo)
    {
        return toAjax(gtMovieListInfoService.updateGtMovieListInfo(gtMovieListInfo));
    }

    /**
     * 删除电影卡片
     */
    @PreAuthorize("@ss.hasPermi('gt:gtmovie:remove')")
    @Log(title = "电影卡片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{movieIds}")
    public AjaxResult remove(@PathVariable Long[] movieIds)
    {
        return toAjax(gtMovieListInfoService.deleteGtMovieListInfoByIds(movieIds));
    }
}
